package officeserver.office.network;

import java.io.Serializable;

import officeserver.office.Office;
import officeserver.office.request.OfficeRequest;

public class RequestQueueWrapper implements Serializable {
    private OfficeRequest request;
    private Office referrer;
    private NetworkConnection net;
    private long timeStarted;
    private long timeFinished;

    public RequestQueueWrapper(OfficeRequest request, Office referrer,
	    NetworkConnection net) {
	super();
	this.request = request;
	this.referrer = referrer;
	this.net = net;
	timeStarted = System.currentTimeMillis();
    }

    public OfficeRequest getRequest() {
	return request;
    }

    public void setRequest(OfficeRequest request) {
	this.request = request;
    }

    public Office getReferrer() {
	return referrer;
    }

    public void setReferrer(Office referrer) {
	this.referrer = referrer;
    }

    public void processRequest() {
	if (request != null) {
	    request.processRequest(referrer);
	    net.enqueOut(request);
	    timeFinished = System.currentTimeMillis();
	}
    }

}
